home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Cinéstore.ifs < prev    next >
Text File  |  2005-03-13  |  9KB  |  272 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=nono.1
  8. Title=CinΘstore
  9. Description=CinΘstore (FR) import avec Affiche
  10. Site=http://www.cinestore.com
  11. Language=FR
  12. Version=26/11/2002
  13. Requires=3.5.0
  14. Comments=crΘation le 21/08/2002 par nono.1| modifiΘ le 17/09/2002 par nono.1| modifiΘ le 14/11/2002 par nono.1| modifiΘ le 26/11/2002 par nono.1|
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19.  
  20. ***************************************************)
  21.  
  22. program Cinestore;
  23. var
  24.   MovieName: string;
  25.  
  26. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  27. var
  28.   i: Integer;
  29. begin
  30.   result := -1;
  31.   if StartAt < 0 then
  32.     StartAt := 0;
  33.   for i := StartAt to List.Count-1 do
  34.     if Pos(Pattern, List.GetString(i)) <> 0 then
  35.     begin
  36.       result := i;
  37.       Break;
  38.     end;
  39. end;
  40.  
  41. procedure AnalyzePage(Address: string);
  42. var
  43.   Page: TStringList;
  44.   LineNr: Integer;
  45. begin
  46.   Page := TStringList.Create;
  47.   Page.Text := GetPage(Address);
  48.   if pos('réponses α votre recherche', Page.Text) = 0 then
  49.   begin
  50.     SetField(fieldURL, Address);
  51.     AnalyzeMoviePage(Page);
  52.   end else
  53.   begin
  54.     PickTreeClear;
  55.     LineNr := 0;
  56.     LineNr := FindLine('href="fiche_produits.php?groupe=1&page=1&id=', Page, LineNr);
  57.     if LineNr > -1 then
  58.     begin
  59.       PickTreeAdd('Films prΘsents', '');
  60.       AddMoviesTitles(Page, LineNr);
  61.     end;
  62.     if PickTreeExec(Address) then
  63.         AnalyzePage(Address);
  64.   end;
  65.   Page.Free;
  66. end;
  67.  
  68. procedure AnalyzeMoviePage(Page: TStringList);
  69. var
  70.   Line, Value,FullValue : string;
  71.   LineNr, IntValue: Integer;
  72.   BeginPos, EndPos: Integer;
  73. begin
  74.   // Picture
  75.   LineNr := FindLine('<img src="http://a333.g.akamai.net/f/333/6918/3h/img.cinestore.com/photo/puce/', Page, 0);
  76.   if LineNr > -1 then
  77.   begin
  78.     Line := Page.GetString(LineNr);
  79.     BeginPos := pos('src="', Line)+5;
  80.     EndPos := pos('" width="50" height="70" class="aimg" border="1"', Line);
  81.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  82.     GetPicture(Value);
  83.   end
  84.    // Translated Title
  85.   LineNr := FindLine('<b>Titre Franτais:</b>', Page, 0);
  86.   if LineNr > -1 then
  87.   begin
  88.     Line := Page.GetString(LineNr+1);
  89.     BeginPos := pos('<font color="#000000">', Line);
  90.     EndPos := pos('</font>', Line);
  91.     Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  92.     HTMLRemoveTags(Value);
  93.     HTMLDecode(Value);
  94.     SetField(fieldTranslatedTitle, Value);
  95.   end;
  96.    // Original Title
  97.   LineNr := FindLine('<b>Titre Original:</b>', Page, 0);
  98.   if LineNr > -1 then
  99.   begin
  100.     Line := Page.GetString(LineNr+1);
  101.     BeginPos := pos('<font color="#000000">', Line);
  102.     EndPos := pos('</font>', Line);
  103.     Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  104.     HTMLRemoveTags(Value);
  105.     HTMLDecode(Value);
  106.     SetField(fieldOriginalTitle, Value);
  107.   end;
  108.     // Description
  109.   LineNr := FindLine('histoire :</b>', Page, LineNr);
  110.   if LineNr > -1 then
  111.   begin
  112.     Line := Page.GetString(LineNr+1);
  113.     BeginPos := pos('<font color="#000000">', Line);
  114.     EndPos := pos('</font>', Line);
  115.     Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  116.     HTMLRemoveTags(Value);
  117.     HTMLDecode(Value);
  118.     SetField(fieldDescription, Value);
  119.   end;
  120.   // Category
  121.   LineNr := FindLine('src="http://a333.g.akamai.net/f/333/6918/3h/img.cinestore.com/images/t/theme_1.gif"', Page, 0);
  122.   if LineNr > -1 then
  123.     begin
  124.      repeat
  125.       LineNr := LineNr+1;
  126.       Line := Page.GetString(LineNr);
  127.      until pos('</tr>', Line) > 0;
  128.      Line := Page.GetString(LineNr+2);
  129.      BeginPos := pos('color="#000000">', Line)+16;
  130.      EndPos := pos('</font></td>', Line);
  131.      Value := copy(Line, BeginPos, EndPos - BeginPos);
  132.      HTMLRemoveTags(Value);
  133.      HTMLDecode(Value);
  134.      SetField(fieldCategory, Value);
  135.     end;
  136.   // Length
  137.   LineNr := FindLine('<B>DurΘe:</b>', Page, 0);
  138.   if LineNr > -1 then
  139.     begin
  140.      Line := Page.GetString(LineNr+1);
  141.      BeginPos := pos('<font color="#000000">', Line);
  142.      EndPos := pos(' mn</font>', Line);
  143.      Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  144.      HTMLRemoveTags(Value);
  145.      HTMLDecode(Value);
  146.      SetField(fieldLength, Value);
  147.     end;
  148.    // Actors
  149.     LineNr := FindLine('<b>Acteurs(s) :</b>', Page, 0);
  150.     if LineNr > -1 then
  151.     begin
  152.      FullValue := '';
  153.      Line := Page.GetString(LineNr);
  154.      repeat
  155.       BeginPos := pos('scrollbars=yes,top=0,left=0,width=330,height=400', Line);
  156.       Delete(Line, 1, BeginPos+51);
  157.       EndPos := pos('</a>', Line);
  158.       Value := copy(Line, 1, EndPos - 1);
  159.       Delete(Line, 1, EndPos+3);
  160.       if FullValue <> '' then
  161.         FullValue := FullValue + ', ';
  162.       FullValue := FullValue + Value;
  163.      until pos(' . </font>',Line) = 1;
  164.     HTMLRemoveTags(FullValue);
  165.     HTMLDecode(FullValue);
  166.     SetField(fieldActors, FullValue);
  167.     end;
  168.   // Director
  169.     LineNr := FindLine('<b>RΘalisateur(s) :</b>', Page, 0);
  170.     if LineNr > -1 then
  171.     begin
  172.      FullValue := '';
  173.      Line := Page.GetString(LineNr);
  174.      Delete(Line, 1, pos('<b>RΘalisateur(s) :</b>',Line));
  175.      repeat
  176.       BeginPos:= pos('scrollbars=yes,top=0,left=0,width=330,height=400',Line);
  177.       Delete(Line, 1, BeginPos+51);
  178.       EndPos := pos('</a>', Line);
  179.       Value := copy(Line, 1, EndPos - 1);
  180.       Delete(Line, 1, EndPos+3);
  181.       if FullValue <> '' then
  182.         FullValue := FullValue + ', ';
  183.       FullValue := FullValue + Value;
  184.      until pos(' . </font>',Line) = 1;
  185.      HTMLRemoveTags(FullValue);
  186.      HTMLDecode(FullValue);
  187.      SetField(fieldDirector, FullValue);
  188.     end;
  189.   // Year
  190.   LineNr := FindLine('<B>Date de sortie du film :</b>', Page, 0);
  191.   if LineNr > -1 then
  192.     begin
  193.      Line := Page.GetString(LineNr+1);
  194.      BeginPos := pos('</font>', Line);
  195.      Value := copy(Line, BeginPos - 4, 4);
  196.      HTMLRemoveTags(Value);
  197.      HTMLDecode(Value);
  198.      SetField(fieldYear, Value);
  199.     end;
  200.   // Commentaires
  201.   LineNr := FindLine('<B>Public :</b>', Page, 0);
  202.   if LineNr > -1 then
  203.     begin
  204.      Line := Page.GetString(LineNr+1);
  205.      BeginPos := pos('<font color="#000000">', Line);
  206.      EndPos := pos('</font>', Line);
  207.      Value := copy(Line, BeginPos + 22, EndPos - BeginPos - 22);
  208.      HTMLRemoveTags(Value);
  209.      HTMLDecode(Value);
  210.      SetField(fieldComments, Value);
  211.     end;
  212.   //DisplayResults;
  213. end;
  214.  
  215. procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
  216. var
  217.   MovieProduct,MovieTitle, MovieAddress, Line, LineProduct: string;
  218.   StartPos, EndPos, LineNRProduct: Integer;
  219. begin
  220.   LineNr := LineNr - 1;
  221.   repeat
  222.     LineNr := LineNr + 1;
  223.     LineNRProduct := LineNr;
  224.     Line := Page.GetString(LineNr);
  225.     StartPos := pos('size="1" color="#3C1A36"><b>', Line);
  226.     if StartPos > 0 then
  227.     begin
  228.       Delete(Line, 1, StartPos);
  229.       StartPos := pos('href="fiche_produits.php?groupe=1', Line);
  230.       Delete(Line, 1, StartPos);
  231.       EndPos := pos('"><font color="#3C1A36">',Line);
  232.       MovieAddress := copy(Line, 44, EndPos -44);
  233.       Delete(Line, 1, EndPos);
  234.       MovieTitle := copy(Line, 24, pos('</font></a>', Line)-24);
  235.       HTMLRemoveTags(MovieTitle);
  236.       HTMLDecode(MovieTitle);
  237.       repeat
  238.         LineNRProduct := LineNRProduct+1;
  239.         LineProduct := Page.GetString(LineNRProduct);
  240.       until (pos('<font color="#3C1A36"><b>de</b>', LineProduct) > 0) or (pos('images/i/invisible.gif" width="60%" height="1" border="0"><img',LineProduct) > 0);
  241.       if pos('images/i/invisible.gif" width="60%" height="1" border="0"><img',LineProduct) > 0 then
  242.       begin
  243.         MovieProduct := '';
  244.       end else
  245.       begin
  246.         StartPos := pos('left=0,width=330,height=400',LineProduct);
  247.         Delete(LineProduct,1,StartPos+30);
  248.         MovieProduct :=copy(LineProduct, 1,pos('</a></font>',LineProduct)-1);
  249.         HTMLRemoveTags(MovieProduct);
  250.         HTMLDecode(MovieProduct);
  251.         MovieProduct := ' (de ' + MovieProduct + ')';
  252.       end;
  253.       PickTreeAdd(MovieTitle+MovieProduct, 'http://www.cinestore.com/html/fiche_produits.php?groupe=1&page=2&id='+MovieAddress);
  254.     end;
  255.   until pos('<font color="#3C1A36">[1]</font>', Line) > 0;
  256. end;
  257.  
  258. begin
  259.   if CheckVersion(3,5,0) then
  260.   begin
  261.     MovieName := GetField(fieldTranslatedTitle);
  262.     if MovieName = '' then
  263.       MovieName := GetField(fieldOriginalTitle);
  264.     if Input('Importation de CinΘstore.com', 'Entrer le titre du film:', MovieName) then
  265.     begin
  266.       AnalyzePage('http://www.cinestore.com/html/liste_mixte.php?CINESTORE=1a5694f56f546666f7761a537b867798&recstr='+UrlEncode(MovieName)+'&grprec=1&type=recherche&id_partenaire=1&x=7&y=8');
  267.     end;
  268.   end else
  269.   ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  270. end.
  271.  
  272.